from common.base_model import BasicModelMixin, CompanyMixin, CreateMixin, UpdateMixin, DeleteMixin
from exts import db
from common import constant


class AccountFlow(BasicModelMixin, db.Model, CompanyMixin, CreateMixin, UpdateMixin, DeleteMixin):
    __tablename__ = 'account_flow'

    id = db.Column(db.Integer, primary_key=True)

    transaction_type = db.Column(db.String, default=constant.TransactionType.PURCHASE, nullable=False)

    account_id = db.Column(db.Integer, db.ForeignKey('account.id'))
    customer_id = db.Column(db.Integer, db.ForeignKey('customer.id'))
    order_id = db.Column(db.Integer)

    # 应收金额
    should_income = db.Column(db.DECIMAL(20, constant.COMMON_DECIMAL), default=0)
    # 应付金额
    should_payment = db.Column(db.DECIMAL(20, constant.COMMON_DECIMAL), default=0)
    # 实收金额
    income = db.Column(db.DECIMAL(20, constant.COMMON_DECIMAL), default=0)
    # 实付金额
    payment = db.Column(db.DECIMAL(20, constant.COMMON_DECIMAL), default=0)
